define(function(require, exports, module) {

  var Backbone = require('backbone');
  var $ = require('jquery');
  var _ = require('underscore');
  var jsonview = require('jsonview');

  var tmpl = require('text!../tmpl.html')

  function main() {
    var $app = $('<div id="app">');
    $('#main').html($app);
    $app.append(tmpl);
    
  }

  function camera() {
    $app.append('<video id="webcam" width="480" height="360"></video>');

    if (navigator.mediaDevices) {
      navigator.mediaDevices.getUserMedia({ video: true, audio: false })
      .then(function onSuccess(stream) {
        var video = document.getElementById('webcam');
        video.autoplay = true;
        video.srcObject = stream;
      })
      .catch(function onError() {
        alert('There has been a problem retreiving the streams - are you running on file:/// or did you disallow access?');
      });
    } else {
      alert('getUserMedia is not supported in this browser.');
    }
  }

  return main;
})
